package com.qkbb.admin.kuibu.qkbb.funcation;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.Toast;

import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;

/**
 * Created by admin on 2016/2/19.
 */
public class HttpPut {
    Context context;
    private String user_token;

    public HttpPut(Context context) {
        this.context = context;
    }

    public void PutData(String type[],String data[],String uri){
        RequestParams params=new RequestParams();
        for(int i=0;i<type.length;i++){
            params.addBodyParameter(type[i],data[i]);
        }
        user_token=SDCardHelper.loadFileFromSdCard("user_token",context);
        Log.e("user_toker",user_token);
        HttpUtils utils=new HttpUtils();
        utils.send(HttpRequest.HttpMethod.PUT, uri+user_token, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Log.e("fshsaj", responseInfo.result);
                Toast.makeText(context, "修改成功", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onFailure(HttpException e, String s) {

            }
        });
    }
    public void PostData(String type[],String data[],String uri){
        RequestParams params=new RequestParams();
        for(int i=0;i<type.length;i++){
            params.addBodyParameter(type[i],data[i]);
        }
        user_token=SDCardHelper.loadFileFromSdCard("user_token",context);
        Log.e("user_toker",user_token);
        HttpUtils utils=new HttpUtils();
        utils.send(HttpRequest.HttpMethod.POST, uri+user_token, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Log.e("fshsaj", responseInfo.result);
                Toast.makeText(context, "修改成功", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onFailure(HttpException e, String s) {

            }
        });
    }
}
